//package com.wushi.lenovo.asia5b.app_ui.good.activity;
//
//import android.content.Intent;
//import android.graphics.Paint;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.text.TextUtils;
//import android.view.View;
//import android.widget.Button;
//import android.widget.CheckBox;
//import android.widget.CompoundButton;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//import com.chad.library.adapter.base.BaseQuickAdapter;
//import com.google.gson.Gson;
//import com.google.gson.JsonObject;
//import com.mvp.base.BaseMvpActivity;
//import com.mvp.common.LocalManageUtil;
//import com.mvp.utils.DecimalUtil;
//import com.mvp.utils.StringUtils;
//import com.mvp.utils.ToastUtil;
//import com.mvp.utils.https.MapHelper;
//import com.wushi.lenovo.asia5b.R;
//import com.wushi.lenovo.asia5b.app_config.BaseEvents;
//import com.wushi.lenovo.asia5b.app_config.CommonConstant;
//import com.wushi.lenovo.asia5b.app_config.MemberBlanceRepository;
//import com.wushi.lenovo.asia5b.app_di.APPComponentFactory;
//import com.wushi.lenovo.asia5b.app_di.goods.component.OrderPaymentPiActivityComponent;
//import com.wushi.lenovo.asia5b.app_di.goods.mvpview.OrderPaymentPiActivityView;
//import com.wushi.lenovo.asia5b.app_di.goods.presenter.OrderPaymentPiActivityPresenter;
//import com.wushi.lenovo.asia5b.app_event.FacebookEvent;
//import com.wushi.lenovo.asia5b.app_model.credit.MemberBlanceModel;
//import com.wushi.lenovo.asia5b.app_model.credit.bean.PayType;
//import com.wushi.lenovo.asia5b.app_model.credit.bean.ThirdTopupType;
//import com.wushi.lenovo.asia5b.app_model.credit.bean.TopupInfoBean;
//import com.wushi.lenovo.asia5b.app_model.good.DeliveriesBean;
//import com.wushi.lenovo.asia5b.app_model.good.GoodsModel;
//import com.wushi.lenovo.asia5b.app_model.good.OrderPayPriceModel;
//import com.wushi.lenovo.asia5b.app_model.good.PaymentMethodModel;
//import com.wushi.lenovo.asia5b.app_model.good.bean.OrderPaymentPiBean;
//import com.wushi.lenovo.asia5b.app_model.good.bean.StepHelper;
//import com.wushi.lenovo.asia5b.app_model.other.UserInfo;
//import com.wushi.lenovo.asia5b.app_model.other.WebUrlType;
//import com.wushi.lenovo.asia5b.app_model.profile.AddressModel;
//import com.wushi.lenovo.asia5b.app_model.voucher.VoucherModel;
//import com.wushi.lenovo.asia5b.app_push.PushHelper;
//import com.wushi.lenovo.asia5b.app_ui.good.activity.pay.PayFpxActivity;
//import com.wushi.lenovo.asia5b.app_ui.good.activity.pay.PayInsActivity;
//import com.wushi.lenovo.asia5b.app_ui.good.activity.pay.PaySufficientActivity;
//import com.wushi.lenovo.asia5b.app_ui.good.activity.pay.PayVisaActivity;
//import com.wushi.lenovo.asia5b.app_ui.good.adapter.OrderPaymentMethodAdapter;
//import com.wushi.lenovo.asia5b.app_ui.good.adapter.OrderPaymentPiGoodAdapter;
//import com.wushi.lenovo.asia5b.app_ui.good.adapter.OrderPaymentPriceAdapter;
//import com.wushi.lenovo.asia5b.app_ui.other.dialog.OrderKouzhaoDialog;
//import com.wushi.lenovo.asia5b.app_ui.other.dialog.SelectVoucherDialogFragment;
//import com.wushi.lenovo.asia5b.app_ui.profile.activity.ChangeAddressActivity;
//import com.wushi.lenovo.asia5b.app_ui.profile.activity.NewAddressActivity;
//import com.wushi.lenovo.asia5b.app_utils.eye.EyeUtils;
//
//import org.greenrobot.eventbus.EventBus;
//import org.greenrobot.eventbus.Subscribe;
//import org.greenrobot.eventbus.ThreadMode;
//
//import java.util.ArrayList;
//import java.util.Iterator;
//import java.util.List;
//import java.util.Map;
//
//import butterknife.BindView;
//import butterknife.OnClick;
//import io.reactivex.Observable;
//
//import static java.lang.String.format;
//import static timber.log.Timber.d;
//
///**
// * Created by zhangyuncai on 2019/10/31.
// * 自营商品付款 todo 因为是自营商品,所以没有本地派送方式
// */
//public class OrderPaymentPiActivity extends BaseMvpActivity<OrderPaymentPiActivityComponent,
//        OrderPaymentPiActivityView, OrderPaymentPiActivityPresenter> implements OrderPaymentPiActivityView {
//
//    @BindView(R.id.view_orderpaymentpi_empty)
//    View view_orderpaymentpi_empty;
//    @BindView(R.id.tv_order_buildname)
//    TextView tv_order_buildname;
//    @BindView(R.id.tv_order_name)
//    TextView tv_order_name;
//    @BindView(R.id.tv_order_address)
//    TextView tv_order_address;
//    @BindView(R.id.tv_order_mobile)
//    TextView tv_order_mobile;
//    @BindView(R.id.tv_order_edit)
//    ImageView tv_order_edit;
//    @BindView(R.id.ll_order_address_vessel)
//    LinearLayout ll_order_address_vessel;
//    //商品列表
//    @BindView(R.id.recyclerview_order_goods)
//    RecyclerView recyclerview_order_goods;
//    @BindView(R.id.tv_order_uservoucher)
//    TextView tv_order_uservoucher;
//    @BindView(R.id.tv_order_uservoucherlist)
//    TextView tv_order_uservoucherlist;
//    @BindView(R.id.et_order_voucherno)
//    EditText et_order_voucherno;
//    @BindView(R.id.et_order_apply)
//    TextView et_order_apply;
//    @BindView(R.id.ll_orderpayment_voucher_vessel)
//    LinearLayout ll_orderpayment_voucher_vessel;
//    @BindView(R.id.tv_order_totalprice)
//    TextView tv_order_totalprice;
//    @BindView(R.id.cb_order_insurance)
//    CheckBox cb_order_insurance;
//    @BindView(R.id.bt_order_submit)
//    Button bt_order_submit;
//    @BindView(R.id.ll_order_bottom)
//    LinearLayout ll_order_bottom;
//    @BindView(R.id.bt_order_newaddres)
//    Button bt_order_newaddres;
//    @BindView(R.id.ll_order_newaddres_vessel)
//    LinearLayout ll_order_newaddres_vessel;
//    //国际派送
//    @BindView(R.id.rv_order_internationalmethod)
//    RecyclerView internationalRecyclerView;
//    //支付方式
//    @BindView(R.id.rv_order_paymentmethos)
//    RecyclerView paymentRecyclerView;
//    //商品价格详情
//    @BindView(R.id.rv_order_pricedetail)
//    RecyclerView pricedetailRecyclerView;
//    @BindView(R.id.tv_orderpayment_weight1)
//    TextView tv_orderpayment_weight1;
//    @BindView(R.id.tv_orderpayment_weight2)
//    TextView tv_orderpayment_weight2;
//    @BindView(R.id.tv_orderpayment_notice)
//    TextView tv_orderpayment_notice;
//    @BindView(R.id.iv_orderpayment_info)
//    ImageView iv_orderpayment_info;
//    @BindView(R.id.tv_orderpaymentpi_address)
//    TextView tv_orderpaymentpi_address;
//    @BindView(R.id.tv_orderpaymentpi_intermethod)
//    TextView tv_orderpaymentpi_intermethod;
//    @BindView(R.id.tv_orderpaymentpi_paymentmethos)
//    TextView tv_orderpaymentpi_paymentmethos;
//    @BindView(R.id.iv_orderpayment_info2)
//    ImageView iv_orderpayment_info2;
//    //收货地址
//    private AddressModel addressModel;
//    //选择优惠券
//    private VoucherModel selectVoucherModel;
//    //商品数据
//    private final List<GoodsModel> goods = new ArrayList<>();
//    //国际派送方式
//    private OrderPaymentMethodAdapter internationalAdapter;
//    //支付方式
//    private OrderPaymentMethodAdapter paymentAdapter;
//    //国际派送方式
//    private String international_delivery_method;
//    //支付方式
//    private String payment_method;
//    //价格详细
//    private OrderPayPriceModel orderPayPriceModel;
//
//    @Override
//    public Map<String, Object> chargesParmas(String international_delivery_method, String payment_method) {
//        this.international_delivery_method = international_delivery_method;
//        this.payment_method = payment_method;
//        return getChargesParmas();
//    }
//
//    @Override
//    public Map<String, Object> chargesParmas(VoucherModel voucherModel) {
//        this.selectVoucherModel = voucherModel;
//        return getChargesParmas();
//    }
//
//    @Override
//    protected int getLayoutId() {
//        return R.layout.activity_orderpaymentpi;
//    }
//
//    @Override
//    protected OrderPaymentPiActivityComponent constructComponent() {
//        return APPComponentFactory.getOrderPaymentPiActivityComponent();
//    }
//
//    @Override
//    protected void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        EventBus.getDefault().register(this);
//        List<GoodsModel> goodsTem = (List<GoodsModel>) getIntent().getSerializableExtra("datas");
//        if (goodsTem != null) {
//            goods.addAll(goodsTem);
//        }
//
//        initView();
//
//        initData();
//
//        initEvent();
//    }
//
//    /**
//     * 初始化视图
//     */
//    @Override
//    protected void initView() {
//        //设置是否显示敏感的icon
//        showMinganIcon();
//        //设置下划线
//        tv_order_uservoucher.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
//        tv_order_uservoucherlist.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
//        /**
//         * 显示商品列表
//         */
//        OrderPaymentPiGoodAdapter adapter = new OrderPaymentPiGoodAdapter(goods);
//        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
//            @Override
//            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
//                if (view.getId() == R.id.ll_orderpayment_price_vessel) {//价格详细
//                    PriceDetailPiActivity.startPriceDetailPiActivity(mActivity, (GoodsModel) adapter.getItem(position));
//                }
//            }
//        });
//        recyclerview_order_goods.setLayoutManager(new LinearLayoutManager(this));
//        recyclerview_order_goods.setAdapter(adapter);
//
//        EyeUtils.setLinkText(this, getString(R.string.paysufficient_notice), getString(R.string.termsconditions),
//                tv_orderpayment_notice, WebUrlType.termsconditions_fpx);
//    }
//
//    /**
//     * 设置是否显示敏感的icon
//     */
//    private void showMinganIcon() {
//        boolean isMingan = false;
//        for (GoodsModel bean : goods) {
//            if (bean.isMingan()) {
//                isMingan = true;
//                break;
//            }
//        }
//        iv_orderpayment_info.setVisibility(isMingan ? View.VISIBLE : View.GONE);
//
//        //步骤1/2/3
//        tv_orderpaymentpi_address.setText(StepHelper.getStep(R.string.orderpayment_step_address, 0));
//        tv_orderpaymentpi_intermethod.setText(StepHelper.getStep(R.string.orderpayment_step_inter, 1));
//        tv_orderpaymentpi_paymentmethos.setText(StepHelper.getStep(R.string.orderpayment_step_paytype, 2));
//
//
//        //数据处理
//        //首先复位
//        for (GoodsModel good : goods) {
//            good.isChecked = false;
//            good.setShopFirstGood(true);
//            good.setShop_total_price(null);
//        }
//        try {
//            //设置是否是店铺下第一个商品
//            for (int i = 0; i < goods.size(); i++) {
//                GoodsModel model = goods.get(i);
//                if (i == 0) {
//                    model.setShopFirstGood(true);
//                } else {
//                    //本商品和上一个商品是否是同一个店铺
//                    model.setShopFirstGood(!TextUtils.equals(model.getShop_id(), goods.get(i - 1).getShop_id()));
//                }
//
//            }
//
//            float totalF = 0f;//最后
//            //给该店铺名下最后一个商品赋予总价格
//            for (int i = 0; i < goods.size(); i++) {
//                GoodsModel model = goods.get(i);
//                totalF += model.getTotalF();
//                if (i == (goods.size() - 1)) {//如果是最后一个
//                    String totalF_text = StringUtils.formatNum(totalF + "", 2);
//                    model.setShop_total_price(String.format("%s %s", model.getUnit(), totalF_text));
//                } else {
//                    GoodsModel nextModel = goods.get(i + 1);
//                    if (!TextUtils.equals(model.getShop_id(), nextModel.getShop_id())) {
//                        String totalF_text = StringUtils.formatNum(totalF + "", 2);
//                        model.setShop_total_price(String.format("%s %s", model.getUnit(), totalF_text));
//                        totalF = 0f;
//                    }
//                }
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    /**
//     * 显示优惠券列表
//     */
//    private void showSelectVoucherDialog() {
//        SelectVoucherDialogFragment selectVoucherDialogFragment = new SelectVoucherDialogFragment();
//        selectVoucherDialogFragment.show(getSupportFragmentManager(), getLocalClassName());
//    }
//
//    /**
//     * 设置地址视图
//     */
//    private void setAddressView() {
//        /*收货地址 ll_order_newaddres_vessel*/
//        if (addressModel == null) {
//            ll_order_newaddres_vessel.setVisibility(View.VISIBLE);
//            ll_order_address_vessel.setVisibility(View.GONE);
//        } else {
//            ll_order_newaddres_vessel.setVisibility(View.GONE);
//            ll_order_address_vessel.setVisibility(View.VISIBLE);
//            //别名 tv_order_buildname
//            if (TextUtils.isEmpty(addressModel.getBuilding_name())) {
//                tv_order_buildname.setVisibility(View.GONE);
//            } else {
//                tv_order_buildname.setVisibility(View.VISIBLE);
//                tv_order_buildname.setText(addressModel.getBuilding_name());
//            }
//            tv_order_buildname.setVisibility(View.GONE);
//            //名字 tv_order_name
//            tv_order_name.setText(addressModel.getContact_name());
//            //地址 tv_order_address
//            tv_order_address.setText(AddressModel.getAddressDetail(addressModel));
//            //电话 tv_order_mobile
//            String phone = format("+%s%s", addressModel.getCalling_code() + "", addressModel.getContact_no());
//            tv_order_mobile.setText(phone);
//        }
//    }
//
//
//    /**
//     * 设置国际运输方式
//     *
//     * @param deliveries
//     */
//    public void setInternationalDeliveryView(List<DeliveriesBean> deliveries) {
//        internationalAdapter = new OrderPaymentMethodAdapter(deliveries == null ? new ArrayList() : deliveries);
//        internationalRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//        internationalRecyclerView.setAdapter(internationalAdapter);
//        internationalAdapter.setOnItemClickListener((adapter, view, position) -> {
//            internationalAdapter.setSelectPosition(position);
//            DeliveriesBean bean = (DeliveriesBean) internationalAdapter.getItem(position);
//            if (!TextUtils.equals(international_delivery_method, bean.getCode())) {
//                international_delivery_method = bean.getCode();
//                getCharges();//①
//            }
//        });
//    }
//
//    /**
//     * 设置支付方式
//     *
//     * @param payments
//     */
//    public void setPaymentMethodView(List<PaymentMethodModel.PaymentsBean> payments) {
//        paymentAdapter = new OrderPaymentMethodAdapter(payments == null ? new ArrayList() : payments);
//        paymentRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//        paymentRecyclerView.setAdapter(paymentAdapter);
//        paymentAdapter.setOnItemClickListener((adapter, view, position) -> {
//            paymentAdapter.setSelectPosition(position);
//            PaymentMethodModel.PaymentsBean bean = (PaymentMethodModel.PaymentsBean) paymentAdapter.getItem(position);
//            if (!TextUtils.equals(payment_method, bean.getCode())) {
//                payment_method = bean.getCode();
//                getCharges();//③
//            }
//        });
//    }
//
//    /**
//     * 选择优惠券
//     *
//     * @param selectVoucherModel
//     */
//    private void setSelectVoucherModel(VoucherModel selectVoucherModel) {
//        this.selectVoucherModel = selectVoucherModel;
//        getCharges();//⑤
//    }
//
//    /**
//     * 设置价格详细
//     *
//     * @param orderPayPriceModel
//     */
//    private void setPriceDetailView(OrderPayPriceModel orderPayPriceModel) {
//        this.orderPayPriceModel = orderPayPriceModel;
//        if (orderPayPriceModel != null) {
//            tv_order_totalprice.setText(orderPayPriceModel.getTotal_text());
//            tv_orderpayment_weight1.setText(format("%s %s", orderPayPriceModel.getTotal_weight(), getString(R.string.kg)));
//            tv_orderpayment_weight2.setText(format("(%s KG Rounding)", orderPayPriceModel.getTotal_weight_before()));
//            List<OrderPayPriceModel.ChargesBean> charges = orderPayPriceModel.getCharges();
//            if (orderPayPriceModel != null && charges != null) {
//                Iterator<OrderPayPriceModel.ChargesBean> iterator = charges.iterator();
//                while (iterator.hasNext()) {
//                    /**
//                     * 因为视图分离,所以移除了这个
//                     */
//                    if (TextUtils.equals(iterator.next().getCode(), "total")) {
//                        iterator.remove();
//                    }
//                }
//                pricedetailRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//                OrderPaymentPriceAdapter priceAdapter = new OrderPaymentPriceAdapter(charges);
//                pricedetailRecyclerView.setAdapter(priceAdapter);
//                priceAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
//                    @Override
//                    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
//                        if (view.getId() == R.id.tv_orderpayment_remove) {//移除优惠券
//                            setSelectVoucherModel(null);
//                        }
//                    }
//                });
//            }
//        } else {
//            tv_order_totalprice.setText("-");
//            tv_orderpayment_weight1.setText("-");
//            tv_orderpayment_weight2.setText("-");
//            pricedetailRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//            OrderPaymentPriceAdapter priceAdapter = new OrderPaymentPriceAdapter(new ArrayList<>());
//            pricedetailRecyclerView.setAdapter(priceAdapter);
//        }
//        bt_order_submit.setEnabled(orderPayPriceModel != null);
//
//    }
//
//
//    @Override
//    protected void initData() {
//        getDefaultAddress();
//    }
//
//    /**
//     * 请求默认地址
//     */
//    private void getDefaultAddress() {
//        getPresenter().getOrderPaymentPiBean(goods, null);
//    }
//
//    /**
//     * 获取商品列表价格
//     * ①派送方式变化时
//     * ②支付方式变化时
//     * ③保险复选框变化时
//     * ④优惠券变化时
//     */
//    private void getCharges() {
//        Map<String, Object> map = getChargesParmas();
//        if (map == null) {
//            return;
//        }
//        getPresenter().getCharges(map);
//    }
//
//    /**
//     * 获取商品列表价格参数
//     *
//     * @return
//     */
//    private Map<String, Object> getChargesParmas() {
//        Map<String, Object> map = MapHelper.newHashMap();
//        if (goods == null || goods.size() == 0) {
//            return null;
//        }
//        if (TextUtils.isEmpty(international_delivery_method) ||
//                TextUtils.isEmpty(payment_method)) {
//            return null;
//        }
//        map.put("member_id", UserInfo.getMemberId());
//        map.put("language_code", LocalManageUtil.getAppLanguage() + "");
//        map.put("products", getPresenter().getProducts(goods));
//        map.put("source", 1);
//        map.put("type", "marketplace");
//        map.put("country_id", UserInfo.getCountryId());
//        map.put("confirm_order", 0);
//        map.put("session_id", PushHelper.getRegistrationId() + "");
//        map.put("extra_data", getExtraData() + "");
//        d("--->>>>>>>>---getCharges:" + map.toString());
//        return map;
//    }
//
//    /**
//     * 拼接扩展参数
//     *
//     * @return
//     */
//    private String getExtraData() {
//        String extraData = null;
//        Map<String, Object> map = MapHelper.newHashMap();
//        map.put("international_delivery_method", international_delivery_method);
//        map.put("payment_method", payment_method);
//        map.put("local_delivery_method", "");
//        Map<String, Object> deliveryAddress = getPresenter().getDeliveryAddress(addressModel);
//        map.put("delivery_address", deliveryAddress);
//        map.put("billing_address", deliveryAddress);
//        map.put("insurance", cb_order_insurance.isChecked() ? "1" : "null");
//        map.put("voucher", selectVoucherModel == null ? "null" : selectVoucherModel.getVoucher_code() + "");
//        extraData = new Gson().toJson(map);
//        return extraData;
//    }
//
//
//    @Override
//    protected void initEvent() {
//        iv_orderpayment_info2.setOnClickListener(v -> {
//            new OrderKouzhaoDialog(mActivity).show();
//        });
//
//        /**
//         * 保险复选框
//         */
//        cb_order_insurance.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//                getCharges();//⑥
//            }
//        });
//    }
//
//    @OnClick({
//            R.id.view_orderpaymentpi_empty,
//            R.id.tv_order_edit,
//            R.id.tv_order_uservoucher,
//            R.id.tv_order_uservoucherlist,
//            R.id.et_order_apply,
//            R.id.bt_order_submit,
//            R.id.bt_order_newaddres,
//            R.id.iv_orderpayment_info
//    })
//    @Override
//    public void onClick(View v) {
//        switch (v.getId()) {
//            /**
//             * 防止点击穿透到下层
//             */
//            case R.id.view_orderpaymentpi_empty:
//                break;
//            case R.id.iv_orderpayment_info: {
//                ToastUtil.showToast(getString(R.string.orderpayment_mingantishi));
//                break;
//            }
//            /**
//             * 修改地址
//             */
//            case R.id.tv_order_edit: {
//                startActivity(new Intent(this, ChangeAddressActivity.class));
//            }
//            break;
//            /**
//             * 新建地址
//             */
//            case R.id.bt_order_newaddres: {
//                Intent intent = new Intent(this, NewAddressActivity.class);
//                intent.putExtra("OrderPayment", true);
//                startActivity(intent);
//            }
//            break;
//            /**
//             * 显隐优惠券输入框
//             */
//            case R.id.tv_order_uservoucher: {
//                int visibility = ll_orderpayment_voucher_vessel.getVisibility();
//                ll_orderpayment_voucher_vessel.setVisibility(visibility == View.GONE ? View.VISIBLE : View.GONE);
//            }
//            break;
//            /**
//             * 显示优惠券列表
//             */
//            case R.id.tv_order_uservoucherlist: {
//                showSelectVoucherDialog();
//            }
//            break;
//            /**
//             * 验证优惠券
//             */
//            case R.id.et_order_apply: {
//                String voucherCode = et_order_voucherno.getText().toString().trim();
//                if (TextUtils.isEmpty(voucherCode)) {
//                    return;
//                }
//                if (orderPayPriceModel == null) {
//                    return;
//                }
//                Map<String, Object> map = MapHelper.newHashMap();
//                map.put("member_id", UserInfo.getMemberId());
//                map.put("code", voucherCode);
//                String extraDataForVoucher = getExtraDataForVoucher();
//                d("--->>>>>>>>---extraDataForVoucher:" + extraDataForVoucher);
//                map.put("extra_data", extraDataForVoucher);
//                map.put("type", "public");//这里是用户自己输入所以就是publice
//                getPresenter().validateVoucher(map);
//            }
//            break;
//            /**
//             * 支付
//             */
//            case R.id.bt_order_submit: {
//                try {
//                    int selectPosition = paymentAdapter.getSelectPosition();
//                    Intent intent = null;
//                    //支付方式
//                    PaymentMethodModel.PaymentsBean bean = (PaymentMethodModel.PaymentsBean) paymentAdapter.getItem(selectPosition);
//                    TopupInfoBean topupInfoBean = new TopupInfoBean();
//                    topupInfoBean.setCheckout_log_id(orderPayPriceModel.getCheckout_log_id());
//                    String total = orderPayPriceModel.getTotal();
//                    topupInfoBean.setTotalAmount(total);
//                    topupInfoBean.setOrderPayPriceModel(orderPayPriceModel);
//                    if (TextUtils.equals(bean.getCode(), PayType.topup.name())) {//我的钱包
//                        MemberBlanceModel memberBlanceModel = MemberBlanceRepository.getMemberBalance();
//                        if (memberBlanceModel == null) {
//                            ToastUtil.showToast(getString(R.string.paymentfailed));
//                            return;
//                        }
//                        String balance_value = memberBlanceModel.getBalance_value();//我的账户余额
//                        //应付金额
//                        String subtractS = DecimalUtil.subtract(balance_value, total);
//                        float subtract = StringUtils.parseFloat(subtractS);
//                        d(format("--->>>>>>>>---value:%s,total:%s,subtract:%s", balance_value + "", total + "", subtract + ""));
//                        if (subtract >= 0) {//余额充足
//                            intent = new Intent(this, PaySufficientActivity.class);
//                        } else {//余额不足
//                            intent = new Intent(this, PayInsActivity.class);
//                        }
//                    } else if (TextUtils.equals(bean.getCode(), PayType.fpx.name())) {//FPX 转账
//                        intent = new Intent(this, PayFpxActivity.class);
//                        topupInfoBean.setDiffAmount(total + "");
//                        topupInfoBean.setThirdTopupType(ThirdTopupType.thirdtopup_from_orderpayment_by_fpx);
//                    } else if (TextUtils.equals(bean.getCode(), PayType.creditcard.name())) {//信用卡
//                        intent = new Intent(this, PayVisaActivity.class);
//                        topupInfoBean.setDiffAmount(total + "");
//                        topupInfoBean.setThirdTopupType(ThirdTopupType.thirdtopup_from_orderpayment_by_creditcard);
//                    }
//                    if (intent != null) {
//                        intent.putExtra(CommonConstant.TopupInfoBean, topupInfoBean);
//                        startActivity(intent);
//                    }
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//            break;
//            default:
//                break;
//        }
//
//    }
//
//    /**
//     * 拼接扩展参数
//     *
//     * @return
//     */
//    public String getExtraDataForVoucher() {
//        JsonObject jsonObject = new JsonObject();
//        jsonObject.addProperty("total_weight", orderPayPriceModel.getTotal_weight());
//        jsonObject.addProperty("total_different", orderPayPriceModel.getTotal_different());
//        jsonObject.addProperty("sub_total", orderPayPriceModel.getSubtotal());
//        jsonObject.addProperty("checkout_log_id", orderPayPriceModel.getCheckout_log_id());
//        return jsonObject.toString();
//    }
//
//    /**
//     * 获取价格详细回调
//     *
//     * @param orderPayPriceModel
//     */
//    @Override
//    public void getChargesResult(OrderPayPriceModel orderPayPriceModel) {
//        setPriceDetailView(orderPayPriceModel);
//    }
//
//    @Override
//    public void getOrderPaymentPiBean(OrderPaymentPiBean orderPaymentPiBean) {
//        //设置商品列表(提前设置了)
//        //设置地址(提前设置了)
//        //设置国际运输方式
//        international_delivery_method = orderPaymentPiBean.getInternational_delivery_method();
//        setInternationalDeliveryView(orderPaymentPiBean.getInternationalDeliveries());
//        //设置付款方式
//        payment_method = orderPaymentPiBean.getPayment_method();
//        setPaymentMethodView(orderPaymentPiBean.getPayments());
//    }
//
//    /**
//     * 此时在UI线程
//     *
//     * @param addressModel
//     */
//    @Override
//    public void getAddressModelResult(AddressModel addressModel) {
//        this.addressModel = addressModel;
//        setAddressView();
//    }
//
//
//    /**
//     * 地址改动通知
//     *
//     * @param event
//     */
//    @Subscribe(threadMode = ThreadMode.MAIN) //在ui线程执行
//    public void onChangeAddress(BaseEvents.ChangeAddressEvent event) {
//        if (event != null && event.addressModel != null) {
//            getPresenter().getOrderPaymentPiBean(goods, Observable.just(event.addressModel));
//        }
//
//
//    }
//
//    /**
//     * 新建地址通知
//     *
//     * @param event
//     */
//    @Subscribe(threadMode = ThreadMode.MAIN) //在ui线程执行
//    public void onNewAddressEvent(BaseEvents.NewAddressEvent event) {
//        if (event != null) {
//            if (addressModel == null) {
//                getDefaultAddress();
//            }
//        }
//
//
//    }
//
//    /**
//     * 支付后通知
//     *
//     * @param event
//     */
//    @Subscribe(threadMode = ThreadMode.MAIN) //在ui线程执行
//    public void onCreditChangeEvent(BaseEvents.CreditChangeEvent event) {
//
//        if (event != null && event.isSuccess()) {
//            if (orderPayPriceModel != null) {
//                FacebookEvent.Companion.ordetPayment(orderPayPriceModel.getTotal());
//            }
//            finish();
//        }
//
//    }
//
//    /**
//     * 选择优惠券
//     *
//     * @param event
//     */
//    @Subscribe(threadMode = ThreadMode.MAIN) //在ui线程执行
//    public void onSelectVoucherEvent(BaseEvents.SelectVoucherEvent event) {
//
//        if (event != null) {
//            setSelectVoucherModel((VoucherModel) event.serializable);
//        }
//
//    }
//
//    @Override
//    public void dismissLoadingBar(Object dississTag) {
//        super.dismissLoadingBar(dississTag);
//        view_orderpaymentpi_empty.setVisibility(View.GONE);
//    }
//
//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//        EventBus.getDefault().unregister(this);
//    }
//}
